/**
 * Created with CLion.
 * Description:
 * User: loong
 * Date: 2024/3/8
 * Time: 10:13
 */

#ifndef CES_PLUGINMANAGER_H
#define CES_PLUGINMANAGER_H
#include "IPluginManager.h"
#include "PluginProperty.h"

namespace CES::Internal {
    class PluginManager : public Core::IPluginManager {
    public:
        PluginManager();

        ~PluginManager() override;

        void SetPluginPaths(const QStringList &_paths) override;

        void LoadPlugins() override;

    private:
        void ReadPlugin();

        QVector<PluginPropertySPtr> LoadQueue();

        static bool LoadQueueImpl(const PluginPropertySPtr &_spec,
                                  QVector<PluginPropertySPtr> &_queue,
                                  QVector<PluginPropertySPtr> &_checkQueue);

        void StopPlugin();

        void DeletePlugin();

    private:
        QStringList pluginPaths_;
        QVector<PluginPropertySPtr> allPluginsProperty_;
        QHash<QString, QVector<PluginPropertySPtr> > pluginCategory_;
        Core::IContextSPtr contextSPtr_{nullptr};
    };
} // namespace CES::Internal


#endif//CES_PLUGINMANAGER_H
